import request from '@/utils/request'

export function getList(params?: any) {
  return request({
    url: '/zgyp-system/api/v1/roles/page',
    method: 'get',
    params,
  })
}

export function doEdit(data: any) {
  return request({
    url: `/zgyp-system/api/v1/roles/${data.id}`,
    method: 'put',
    data,
  })
}

export function doDelete(data: any) {
  return request({
    url: `/zgyp-system/api/v1/roles/${data.ids}`,
    method: 'delete',
    data,
  })
}

/**
 * 角色详情列表
 */
export function fetchRoleDetail(params?: any) {
  return request({
    url: `/zgyp-system/api/v1/roles/${params.roleId}/form`,
    method: 'get',
    params,
  })
}
/**
 * 角色菜单下拉列表
 */
export function fetchRoleMenusList(params?: any) {
  return request({
    url: '/zgyp-system/api/v1/roles/options',
    method: 'get',
    params,
  })
}

/**
 * 获取角色的菜单ID集合
 */

export function fetchRoleroleMenuIds(params?: any) {
  return request({
    url: `/zgyp-system/api/v1/roles/${params.roleId}/menuIds`,
    method: 'get',
    params,
  })
}

/**
 * 分配角色以及按钮权限
 * data
 */
export function editRoleroleMenuAllot(data?: any) {
  return request({
    url: `/zgyp-system/api/v1/roles/${data.roleId}/menus`,
    method: 'put',
    data: data.tree,
  })
}
